import type { WalletConnector } from '../'
import { computed } from 'vue'

export function useHasCondition(wallet: WalletConnector) {
  const getContentCondition = computed(() => {
    const { downloadUrls, qrCode, extensionDownloadUrl, desktopDownloadUrl } = wallet
    const hasMobileCompanionApp = downloadUrls?.qrCode && qrCode
    const hasExtension = !!extensionDownloadUrl
    const hasMobileAndExtension = downloadUrls?.qrCode && hasExtension
    const hasMobileAndDesktop = downloadUrls?.qrCode && !!desktopDownloadUrl

    return {
      hasExtension,
      hasMobileAndDesktop,
      hasMobileAndExtension,
      hasMobileCompanionApp
    }
  })

  const isMobile = computed(() => {
    return wallet?.downloadUrls?.qrCode
  })

  const isDesktop = computed(() => {
    return !!wallet?.desktopDownloadUrl
  })

  const isExtension = computed(() => {
    return !!wallet?.extensionDownloadUrl
  })

  return {
    getContentCondition,
    isMobile,
    isDesktop,
    isExtension
  }
}
